<template>
  <!-- <div class="flex"> -->
    <!-- 操作区域 -->
      <div class="flex-row">
      <!-- 档案记录区域汇总信息区域 -->
      <div class="flex" style="width: 370px;margin-right: 15px;">
        <div novalidate class="flex-row auto" >
          <div class="from-group flex-row" style="flex: 1;">

            <label  style="line-height: 33px;">归属期</label>
            <datepicker  placeholder="归属期"
              v-model="model.startDate"
              :value.sync="model.startDate"
              :format="'yyyy-MM-dd'"
              width="100px"></datepicker>
              <!-- <label style="line-height: 33px;">归属期</label> -->
              <!-- <input type="text" class="form-control" v-model="model.startDate"
    					placeholder='开始日期'
              :size="model.startDate ? model.startDate.length : 4" style="flex: 1;"> -->
            <!-- </div> -->
            <!-- <div class="from-group flex-row" style="flex: 1;"> -->
               <!-- <label style="line-height: 33px;padding-left: 10px;">至</label> -->
               <!-- <input type="text" class="form-control" v-model="model.endDate"
     					 placeholder='结束日期'
               :size="model.endDate ? model.endDate.length : 4" style="flex: 1;margin-right:10px;"> -->
               <label  style="line-height: 33px;">至</label>
               <datepicker  placeholder="归属期"
                 v-model="model.endDate"
                 :value.sync="model.endDate"
                 :format="'yyyy-MM-dd'"
                 width="100px"></datepicker>

              <!-- <button class="btn btn-success active" @click="">抄表单生成</button> -->
          </div>
          <div class="form-group">
              <button class="btn btn-success width-80" @click="search(), reflashChild()">查询</button>
          </div>
          <!-- <div class="form-group" style="margin-left:200px;">
            <button class="btn btn-success active" @click="search(), $parent.$parent.clean()">同步档案</button>
          </div> -->
        </div>
        <!-- <hand-issued :date="model.f_hand_date" v-ref:iss @down-complete="search"></hand-issued> -->
        <div class="span" id="nopadding-table">
          <partial-view v-ref:pv id="partial-view">
          <data-grid :model="model" partial='list' v-ref:grid style="flex: 1">
            <template partial='head'>
              <tr>
                 <th>抄表员</th>
                 <th>总户数</th>
                 <th>应抄</th>
                 <th>未下发</th>
                 <th>已抄表</th>
                 <th>未抄表</th>

              </tr>
            </template>
            <template partial='body'>
              <td>{{row.f_inputtor}}</td>
              <td>
                {{row.alls}}
              </td>
              <td><span class="btn btn-link"
                @click.stop="$parent.$parent.$parent.searchGather(row.f_inputtor, '', row.oughtnums)">{{row.oughtnums}}</span></td>
              <td><span class="btn btn-link"
                @click.stop="$parent.$parent.$parent.searchGather(row.f_inputtor, '未下发', row.weixiafa)">{{row.weixiafa}}</span></td>
              <td><span class="btn btn-link"
                @click.stop="$parent.$parent.$parent.searchGather(row.f_inputtor, '已抄表', row.yichao)">{{row.yichao}}</span></td>
              <td><span class="btn btn-link"
              @click.stop="$parent.$parent.$parent.searchGather(row.f_inputtor, '未抄表', row.weichao)">{{row.weichao}}</span></td>
            </template>
          </data-grid>
          </partial-view>
        </div>
      </div>
      <hand-manager :operater="operater" :sgnetwork = "sgnetwork" :start-date='model.startDate' :end-date='model.endDate'
      v-ref:hand @change-inputtor="search" @down-complete="search(), reflashChild()" @cancel-hand="search(), reflashChild()"
      @delect-hand="search(), reflashChild()" @hand-reverse="search(), reflashChild()"></hand-manager>
      <card-list :btns="operatebtn" :userinfoid="row ? row.f_userinfo_id : ''" @select-oper="showWork" :is-operate="false"></card-list>
    </div>

  <!-- </div> -->
</template>

<script>
/**
*机表管理
*抄表管理组件
*/
import * as Util from '../../Util'
// import AppData from '../../stores/AppData'

export default {
  title: '抄表管理',
  data () {
    return {
      btns: ['票据补打', '冲正'],
      operater: Util.f.name, // 操作员
      // sgnetwork: Util.f.orgpathstr, // 网点
      sgnetwork: Util.f.parentname, // 网点
      model: {
        // startDate: Util.toStandardYearMonth().replace("-", ""),
        // endDate: Util.toStandardYearMonth().replace("-", ""),
        startDate: Util.toStartAndEndDateString()[0],
        endDate: Util.toStartAndEndDateString()[1],
        f_inputtor: Util.f.name,
        rows: []
      }
    }
  },
  ready () {
    this.search()
    // this.reflashChild()
  },
  methods: {
    search () {
      let condition = '1=1'
      // 如果隶属总公司，不加任何判断
      if (!Util.f.parent.parent.name.includes('统一资源管理')) {
        condition += ` and f_filiale = '${Util.f.f_fengongsi}'`
      }
      this.$refs.pv.load('rs/sql/periodInputor', {data: {startDate: this.model.startDate,endDate: this.model.endDate, condition: condition}}, {resolveMsg: null, rejectMsg: null}).then((res) => {
        this.model.rows = res.data
      })
    },
    searchGather (inputtor, state, num) {
      this.$refs.hand.searchGather(inputtor, state, num)
    },
    reflashChild () {
      this.$refs.hand.reflash()
    }
  }
}
</script>
<style lang="less">
  #partial-view div{
    height: auto;
  }
  #nopadding-table {
    th,
    td {
      padding: 8px 0px;
      text-align: center;
    }
  }
</style>
